<?php

class User extends AppModel {

    var $name = 'User';
    var $displayField = 'id';
    var $validate = array(
        'id' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Campo requerido',
            ),
            'numeric' => array(
                'rule' => array('numeric'),
                'message' => 'Campo inválido',
            ),
        ),
        'username' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Campo requerido',
                'last' => true,
            ),
            'isUnique' => array(
                'rule' => array('isUnique'),
                'message' => 'Este nombre de usuario ya ha sido asignado.',
                'last' => true,
            ),
            'custom' => array(
                'rule' => array('custom', '/^[a-zA-Z0-9]{3,}$/i'),
                'message' => 'Sólo letras y enteros.',
                'last' => true,
            ),
            'between' => array(
                'rule' => array('between', 5, 20),
                'message' => 'Los nombres de usuario deben tener una longitud de entre 5 y 20 caracteres.',
                'last' => true
            ),
        ),
        'password' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Campo requerido',
                'last' => true,
            ),
            'custom' => array(
                'rule' => array('custom', '/^[a-zA-Z0-9]{3,}$/i'),
                'message' => 'Sólo letras y enteros.',
                'last' => true,
            ),
            'between' => array(
                'rule' => array('between', 8, 50),
                'message' => 'Las contraseñas deben tener una longitud de entre 8 y 50 caracteres.',
                'last' => true
            ),
        ),
        'group_id' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Campo requerido',
            ),
            'numeric' => array(
                'rule' => array('numeric'),
                'message' => 'Campo inválido',
            ),
        ),
    );
    //The Associations below have been created with all possible keys, those that are not needed can be removed
    var $belongsTo = array(
        'Group' => array(
            'className' => 'Group',
            'foreignKey' => 'group_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );
}
?>